<%@ page import="yc.day0109.lottery.dao.UserDao" %>
<%@ page import="yc.day0109.lottery.dao.impl.UserDaoImpl" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %>
<%@ page import="yc.day0109.lottery.po.User" %>
<%@ page import="yc.day0109.lottery.constants.UserStatus" %><%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2023/1/9
  Time: 13:14
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <title>燃油汽车指标摇号系统管理平台</title>
    <link rel="stylesheet" href="../../../css/yc/day0109/index.css">
<%--    <script src="../../../js/yc/day0109/jquery-3.6.3.js"></script>--%>
<%--    <script src="../../../js/yc/day0109/add.js"></script>--%>
    <%
        //jsp组成部分：jsp小脚本  内置对象(9个内置对象)  jsp指定  注释
        /*在jsp页面中获取后端Java程序，进行数据交互*/
        //1.使用多态体现，创建实例化UserDao数据访问层
        UserDao userDao = new UserDaoImpl();
        //2.创建Map集合对象，用来存储查询列表的搜索条件参数
        Map<String,Object> map = new HashMap<>();
        //2.1.获取indexController.jsp中存储在request作用域中的searchName
        String searchName = request.getAttribute("searchName") == null ? "" :
                String.valueOf(request.getAttribute("searchName"));
        if(!"".equals(searchName)){
            map.put("markNo",searchName);
        }
        //3.调用查询列表方法
        List<User> userList = userDao.queryUserByType(map);

    %>
</head>
<body>
<div id="container">
    <header>燃油汽车指标摇号系统</header>
    <div id="main_body">
        <div id="aside">
            <h2>功能列表展示</h2>
            <a href="#">参与摇号用户</a>
            <a href="Lottery.html">摇号</a>
        </div>
        <div id="main_center">
            <form action="indexController.jsp" method="post">
                <div id="search">
                    <button name="btnSeach" id="ch"><a href="addUser.jsp">添加</a></button>                    <input class="user-input" type="text" name="search" placeholder="中签编码">
                    <!-- <input class="user-btn" type="button" value="搜索""> -->
                    <button>搜索</button>
                </div>
                <table>
                    <thead>
                    <tr>
                        <th>姓名</th>
                        <th>中签编码</th>
                        <th>持照状态</th>
                        <th>手机号码</th>
                        <th>开户日期</th>
                        <th>操作</th>
                    </tr>
                    <%
                        for (int i = 0; i < userList.size(); i++) {
                    %>
                    <tr>
                        <td><%=userList.get(i).getUserName()%></td>
                        <td><%=userList.get(i).getMarkNo()%></td>
                        <td><%=UserStatus.getUserStatusByCode(userList.get(i).getStatus()).getValue()%></td>
                        <td><%=userList.get(i).getPhone()%></td>
                        <td><%=userList.get(i).getOpenDate()%></td>
                        <td><a href="">详情</a>&nbsp;<a href="">删除</a></td>
                    </tr>

                    <%}%>
                    </thead>
                    <tbody class="last">

                    </tbody>
                </table>
            </form>
        </div>
    </div>
</div>
</body>
</html>
